<template>
  <div>
    <div style="height:20px;"></div>
    <LazyLoadTab v-model="activeName" :tabMenus="menus"></LazyLoadTab>
    <div style="height:47px;"></div>

    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
    <multiuse-button type="primary" :click="closeDrawer.bind(this, 2)" :disabled="isOpen">驳 回</multiuse-button>
      <el-button @click="closeDrawer(1)">关 闭</el-button>

      <multiuse-button type="primary" :click="closeDrawer.bind(this, 3)" :disabled="isOpen">通 过</multiuse-button>
      <!-- <el-button @click="closeDrawer(2)" type="primary" :disabled='isOpen'>驳回</el-button>
      <el-button @click="closeDrawer(3)" type="primary" :disabled='isOpen'>通过</el-button> -->
    </div>
  </div>
</template>
<script>
import {getDetail,updatePlateApply} from '@/api/omSale/subsidy/subsidyAudit/index.js'
export default {
  data(){
    return{
      json:{},
      activeName: '基础信息',
      isOpen:true,
      menus: [
        {
          title: '基础信息',
          path: 'omSale/subsidy/subsidyAudit/BasicsChildren',
          params:{
            data:{},
            reject:0
          },
          on:{
            'changeDesc':this.changeDesc
          }

        },
        {
          title: '发票行驶证附件',
          path: 'omSale/subsidy/subsidyAudit/InvoiceAttachment',
          params:{
            data:{}
          },

        },
        {
          title: '车辆信息',
          path: 'omSale/subsidy/subsidyAudit/carChildren',
          params:{
            data:{}
          },

        },
        {
          title: '其他附件',
          path: 'omSale/subsidy/subsidyAudit/otherModel',
          params:{
            data:{}
          },

        },
      ]
    }
  },
  components:{
  },
  props:['rowData'],
  created(){
    this.getDetail(this.rowData)
  },
  methods:{
    async getDetail(data){
      let res=await getDetail({id:data.id})
      this.menus.map(x=>{
        x.params.data=res.data
      })
      if(res.data.applyStatus!=60191002){
        this.isOpen=true;
      }else{
        this.isOpen=false;
      }
    },
    async changeDesc(val,type){
      console.log(val,'222')
      this.menus[0].params.reject=0;
      // 1是驳回2是通过
        if(type==1){
          if(val){
            let json={checkDesc:val}
            json.id=this.rowData.id;
            json.applyStatus=60191004;
            let res = await updatePlateApply(json);
            if (res.resultCode == 200) {
              this.$notify({
                title: '成功',
                message: '驳回成功',
                type: 'success'
              });
              this.$emit('close', json);
            }
          }
        }else if(type==2){
          let json={checkDesc:val}
          json.id=this.rowData.id;
          json.applyStatus=60191003;
          let res = await updatePlateApply(json);
          if (res.resultCode == 200) {
            this.$notify({
              title: '成功',
              message: '通过成功',
              type: 'success'
            });
            this.$emit('close', json);
          }
        }


    },
    async closeDrawer(type){
      console.log()
      if(type==1){
        this.$emit('close')
      }else if(type==2){
       this.menus[0].params.reject=1;
      }else{
        this.menus[0].params.reject=2;
      }
    }
  }
}
</script>
